open(FH,"/Volumes/HD_2/Documents/lab/project/SNP/Normal_SNP.chr11.7M-9M.txt");
my @in=<FH>;
chomp(@in);
close(FH);
my $count = 0;
my $count_het = 0;
my $count_array_het = 0;
my $count_array_hom = 0;
my $count_hom = 0;
my $fp = 0;
my $fn = 0;
my $total_count=0;
open(FH,"/Volumes/HD_2/Documents/workspace/snps.raw.variantonly.test.vcf");
my @vcf=<FH>;
chomp(@vcf);
close(FH);
my %vcf_hash = ();
foreach my $line(@vcf){
	next if $line=~/^\#/;
	my @splitvcf=split "\t",$line;
	#next if $splitvcf[5] <=4;
	$vcf_hash{$splitvcf[2]} = $line;
	if($splitvcf[4]=~/[AGCT]\,/){
		#if($splitvcf[9]=~/1\/1/){
		#	print("$line\n");
		#}
	}
}
foreach my $line(@in){
	my @splitin=split "\t",$line;
	if($splitin[3] ne $splitin[4]){
		$count_array_het++;
		
	}
	else{
		$count_array_hom++;
	}
	if( exists $vcf_hash{$splitin[0]} ){
		$count++;
		my @splitvcf=split "\t",$vcf_hash{$splitin[0]};
		if($splitvcf[9]=~/0\/1/){
			$count_het++;
			if($splitin[3] eq $splitin[4]){
				$fp++;
				print("fp:\t$splitin[0]\t$splitin[1]\t$splitin[2]\n");
			}
		}
		else{
			if($splitvcf[4]=~/[AGCT]\,/){
				$count_het++;
				if($splitin[3] eq $splitin[4]){
					$fp++;
					print("fp:\t$splitin[0]\t$splitin[1]\t$splitin[2]\n");
				}
			}
			else{
				if($splitin[3] ne $splitin[4]){
					$fn++;
					if($line=~/\d+\tA\tB\tA\tG/ or $line=~/\d+\tA\tB\tG\tA/ or $line=~/\d+\tA\tB\tT\tC/ or $line=~/\d+\tA\tB\tC\tT/){
						$ag_count++;
					}
					print("false neg:\t$splitin[0]\t$splitin[1]\t$splitin[2]\n");
				}
				$count_hom++;
			}
			
		}
	}
	else{
		if($splitin[3] ne $splitin[4]){
			$fn++;
			if($line=~/\d+\tA\tB\tA\tG/ or $line=~/\d+\tA\tB\tG\tA/ or $line=~/\d+\tA\tB\tT\tC/ or $line=~/\d+\tA\tB\tC\tT/){
				$ag_count++;
			}
			print("false neg:\t$splitin[0]\t$splitin[1]\t$splitin[2]\n");
		}
		$count_hom++;
	}
}
my $fp_rate = $fp/$count_array_hom;
my $fn_rate = $fn/$count_array_het;

print("het count is: $count_het\n");
print("array het count is: $count_array_het\n");
print("array hom count is: $count_array_hom\n");
print("false pos num is: $fp\t fp rate is: $fp_rate\n");
print("false neg num is: $fn\t fn rate is: $fn_rate\n");